//
//  CompanyApplicationSuccess.m
//  jingjing2.0
//
//  Created by apple on 16/5/20.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "CompanyApplicationSuccess.h"
#import "WriteApplicationViewController.h"
#define  WIDTH [UIScreen mainScreen].bounds.size.width
@implementation CompanyApplicationSuccess
-(id)initWithFrame:(CGRect)frame
{
    if (self=[super initWithFrame:frame]) {
        self.backgroundColor=LIGHTGRAY;
        UIImageView *image=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"apply_succes"]];
        image.frame=CGRectMake(30, 10, WIDTH-60, 100);
        [self addSubview:image];
        UILabel *title=[[UILabel alloc]initWithFrame:CGRectMake(20, 10, image.frame.size.width-40, 20)];
        title.textColor=[UIColor whiteColor];
        title.font=[UIFont systemFontOfSize:15];
        title.textAlignment=NSTextAlignmentCenter;
        title.text=@"恭喜您开通净净洗衣";
        [image addSubview:title];
        
        UILabel *name=[[UILabel alloc]initWithFrame:CGRectMake(20, title.frame.origin.y+20+5, image.frame.size.width-40, 30)];
        name.textColor=[UIColor whiteColor];
        name.font=[UIFont boldSystemFontOfSize:17];
        name.textAlignment=NSTextAlignmentCenter;
        name.text=@"企业福利";
        [image addSubview:name];
        
        UILabel *company=[[UILabel alloc]initWithFrame:CGRectMake(5, image.frame.size.height-10-20, image.frame.size.width-10, 20)];
        company.textColor=[UIColor whiteColor];
        company.font=[UIFont systemFontOfSize:13];
        company.textAlignment=NSTextAlignmentCenter;
        company.text=[NSString stringWithFormat:@"开通企业  %@",GETCompanyName];
        [image addSubview:company];

        
        for (int i=0; i<4; i++) {
            UILabel *lbl=[[UILabel alloc]initWithFrame:CGRectMake(10, i*(20+5)+image.frame.origin.y+100+10, WIDTH-20, 20)];
            lbl.textColor=[UIColor darkGrayColor];
            lbl.font=[UIFont systemFontOfSize:15];
            lbl.textAlignment=NSTextAlignmentCenter;
            if (i==0) {
                lbl.text=@"企业福利使用手册已发送至您";
            }else if (i==1)
            {
                if (GETEmail) {
                    NSString *text=[NSString stringWithFormat:@"邮箱%@ 注意查收～",GETEmail];
                    NSInteger length=[NSString stringWithFormat:@"邮箱%@",GETEmail].length;
                    NSMutableAttributedString *attriString = [[NSMutableAttributedString alloc] initWithString:text];
                    
                    //把价格的字体颜色变为红色
                    [attriString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, length)];
                    [attriString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:13] range:NSMakeRange(0, length)];
                    [lbl setAttributedText:attriString];
                }
            }else if(i==2)
            {
                lbl.text=@"更多问题可咨询净净服务热线";
            }else
            {
                 lbl.text=@"4000-123-299";
                lbl.textColor=BLUECOLOR;
                lbl.font=[UIFont systemFontOfSize:20];
                _rect=lbl.frame;
            }
            [self addSubview:lbl];
        }
        UIImageView *phone=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"custom_service"]];
        phone.frame=CGRectMake(_rect.origin.x+30, _rect.origin.y, 25, 25);
        [self addSubview:phone];
        
        UIButton *btn=[[UIButton alloc]initWithFrame:CGRectMake(10, frame.size.height-10-40, WIDTH-20, 40)];
        [btn setTitle:@"返回首页" forState:UIControlStateNormal];
        [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        btn.layer.cornerRadius=4;
        btn.clipsToBounds=YES;
        [btn addTarget:self action:@selector(backToHomeView) forControlEvents:UIControlEventTouchUpInside];
        btn.backgroundColor=BLUECOLOR;
        [self addSubview:btn];
        
        UIButton *share=[[UIButton alloc]initWithFrame:CGRectMake(10, frame.size.height-10-40-10-40, WIDTH-20, 40)];
        [share setTitle:@"分享给我的好友" forState:UIControlStateNormal];
        [share setTitleColor:BLUECOLOR forState:UIControlStateNormal];
        share.layer.cornerRadius=4;
        share.clipsToBounds=YES;
        share.layer.borderWidth=1;
        share.layer.borderColor=BLUECOLOR.CGColor;
        [share addTarget:self action:@selector(shareToMyFriend) forControlEvents:UIControlEventTouchUpInside];
        share.backgroundColor=[UIColor whiteColor];
        [self addSubview:share];

    }
    return self;
}
-(void)shareToMyFriend
{
    
}
-(void)backToHomeView
{
    [_delegate backToHomeView];
}

@end
